import request from "@/utils/request";

//admin权限级别接口
/**
 * 添加item,供Admin使用
 */
export function addItem(row) {
  return request({
    url: "/items",
    method: "post",
    data: row
  });
}
/**
 * 查询item分页,供后台使用
 */
export function getItemByPage(pageVo) {
  return request({
    url: "/items/search",
    method: "post",
    data: pageVo
  });
}
/**
 * 根据id主键获取单条记录
 */
export function getItem(id) {
  return request({
    url: "/items/" + id
  });
}

/**
 * 根据主键id更新指定行的数据
 */
export function updateItemById(row) {
  return request({
    url: "/items/" + row.id,
    method: "put",
    data: row
  });
}
/**
 * // 根据id主键删除单条记录
 */
export function removeItemById(id) {
  return request({
    url: "/items/" + id,
    method: "delete"
  });
}
//商品上架
export function turnOnSale(itemId) {
  return request({
    url: "/items/" + itemId + "/sale_on",
    method: "put"
  });
}
//商品下架
export function turnOffSale(itemId) {
  return request({
    url: "/items/" + itemId + "/sale_off",
    method: "put"
  });
}
